
#include <BCube>
#include <BCone>
#include <BCylinder>
#include <BCapsule>
#include <BSphere>
#include "member_BShape.h"
#include "ITriangleShape.h"

using namespace BWE;

member_BShape::member_BShape(BShape* shape)
{
	boss = shape;
	isolate = false;
	visible = true;
	colliding = true;
	transparent = false;

	color.set(255, 255, 255, 255);

	normalize = false;
	lighting = true;
	depthTest = true;
	depthOffset = 0.0f;
	cullback = true;
	pointSmooth = true;
	pointSize = 1.0f;
	lineSmooth = true;
	lineWidth = 1.0f;
	polySmooth = true;
	polyMode = Poly_Fill;
	margin = 0;

	dirty = true;
	dirtySpace = true;
}
member_BShape::~member_BShape()
{

}

void member_BShape::slotMaterialEnabled(BObject* object)
{
	boss->emit(Signal_Freshed);
}
void member_BShape::slotMaterialChanged(BObject* object)
{
	boss->emit(Signal_Freshed);
}

void member_BShape::slotTextureEnabled(BObject* object)
{
	boss->emit(Signal_Freshed);
}
void member_BShape::slotTextureDirty(BObject* object)
{
	boss->emit(Signal_Freshed);
}

void member_BShape::slotProgramEnabled(BObject* object)
{
	boss->emit(Signal_Freshed);
}
void member_BShape::slotProgramDirty(BObject* object)
{
	boss->emit(Signal_Freshed);
}

BSpace member_BShape::transSpace(const BMatrix& matrix) const
{
	const BBox& box = boss->box();
	BSpace space(matrix * box.center());
	space.expand(matrix * box.v0());
	space.expand(matrix * box.v1());
	space.expand(matrix * box.v2());
	space.expand(matrix * box.v3());
	space.expand(matrix * box.v4());
	space.expand(matrix * box.v5());
	space.expand(matrix * box.v6());
	space.expand(matrix * box.v7());
	return space;
}

